/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jpa.sessions;

import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import jpa.entities.Property;

/**
 *
 * @author JAVA
 */
@Stateless
public class PropertyFacade extends AbstractFacade<Property> {
    @PersistenceContext(unitName = "MySweetHomePU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public PropertyFacade() {
        super(Property.class);
    }

    public Collection findByAccomodation(double maxDeposit, double minDeposit, double maxRent, double minRent,String city) {
        return em.createNamedQuery("Property.findByAccomodation")
                .setParameter("minDeposit", minDeposit)
                .setParameter("maxDeposit", maxDeposit).setParameter("minRent",minRent)
                .setParameter("city", city)
                .setParameter("maxRent", maxRent).getResultList();

    }

}
